package top.kaoshanji.p2ch10a.support;

/**
 * author kaoshanji
 * ^_^
 * create time 2025/2/2 20:18
 */
public class MutableObject implements Cloneable {

    private Counter counter = new Counter();

    public void increase() {
        counter.increase();
    }

    public int getValue() {
        return counter.getValue();
    }

    @Override
    public Object clone() {
        MutableObject obj;

        try {
            obj = (MutableObject) super.clone();
            obj.counter = (Counter) counter.clone();

            return obj;
        } catch (CloneNotSupportedException e) {
            throw new Error(e);
        }
    }
}
